﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Fatura.aspx.cs" Inherits="WebFatura.Fatura" %>

<%@ Register Assembly="DevExpress.Web.v12.1, Version=12.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dx" %>

<%@ Register Assembly="DevExpress.Web.v12.1, Version=12.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxTabControl" TagPrefix="dxd" %>

<%@ Register Assembly="DevExpress.Web.ASPxEditors.v12.1, Version=12.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>

<%@ Register Assembly="DevExpress.Web.ASPxGridView.v12.1, Version=12.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dx" %>

<%@ Register Assembly="DevExpress.Web.v12.1, Version=12.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxClasses" TagPrefix="dx" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta charset="UTF-8" />
    <!-- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">  -->
    <title>Mikro Web</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="description" content="Login and Registration Form with HTML5 and CSS3" />
    <meta name="keywords" content="html5, css3, form, switch, animation, :target, pseudo-class" />
    <meta name="author" content="Codrops" />
    <link rel="shortcut icon" href="../favicon.ico" />
    <link rel="stylesheet" type="text/css" href="css/demo.css" />
    <link rel="stylesheet" type="text/css" href="css/style.css" />
    <style type="text/css">
        .auto-style1 {
            width: 970px;
        }

        .auto-style8 {
            width: 161px;
        }

        .auto-style10 {
            width: 161px;
            height: 27px;
        }

        .auto-style11 {
            width: 162px;
            height: 27px;
        }

        .auto-style12 {
            width: 199px;
            height: 27px;
        }

        .auto-style13 {
            width: 199px;
        }

        .auto-style14 {
            width: 470px;
            height: 27px;
        }

        .auto-style15 {
            width: 470px;
        }

        .auto-style16 {
            width: 63px;
            height: 27px;
        }

        .auto-style17 {
        }

        .auto-style18 {
            width: 224px;
            height: 27px;
        }

        .auto-style19 {
            width: 224px;
        }

        .auto-style24 {
            height: 27px;
        }

        .auto-style30 {
            width: 100%;
            height: 100%;
            margin-top: 0px;
        }

        .auto-style31 {
            width: 100px;
        }

        .auto-style32 {
            width: 259px;
        }

        .auto-style33 {
            width: 419px;
        }

        .auto-style34 {
            height: 26px;
        }

        .auto-style37 {
            width: 37px;
        }

        .auto-style38 {
            width: 94px;
        }

        .auto-style39 {
            width: 82px;
        }

        .auto-style40 {
            width: 82px;
            height: 17px;
        }

        .auto-style41 {
            width: 94px;
            height: 17px;
        }

        .auto-style42 {
            width: 37px;
            height: 17px;
        }

        .auto-style43 {
            height: 17px;
        }

        .auto-style44 {
            width: 100%;
        }

        .auto-style46 {
            height: 380px;
        }
    </style>
    <script type="text/javascript">

        var teksefer = true;

        function ProcessClick() {
            var miktar = 1;
            if (txtMiktar.GetText() != "") {
                miktar = parseFloat(txtMiktar.GetText());
            }

            teksefer = true;
            GridCallasp.PerformCallback('ekle;' + GridCallasp.GetFocusedRowIndex() + ";" + miktar);
            //var tab = tabPage.GetTab(1);
            //tabPage.SetActiveTab(tab);

            GridLine.PerformCallback('guncelle;' + miktar + ';' + 0);
        }

        function Guncelle() {
            var miktar = 1;
            if (txtMiktar.GetText() != "") {
                miktar = parseFloat(txtMiktar.GetText());
            }
            GridLine.PerformCallback('guncelle;' + miktar + ';' + GridLine.GetFocusedRowIndex());
        }

        function OnGetRowValues(values) {
            var aratop = parseFloat(txtAraToplam.GetText());
            var kdvtop = parseFloat(txtKdv.GetText());
            var yekun = parseFloat(txtYekun.GetText());

            aratop = aratop + values[0];
            txtAraToplam.SetText(aratop.toFixed(2));
            var kdvtop = aratop / 100 * values[1];
            txtKdv.SetText(kdvtop.toFixed(2))
            txtYekun.SetText((aratop + kdvtop).toFixed(2));
        }

        function CalcLines() {
            txtAraToplam.SetText(0);
            txtKdv.SetText(0);
            txtYekun.SetText(0);

            for (var i = 0; i < GridLine.pageRowCount; i++) {
                GridLine.GetRowValues(i, 'Tutar;KdvOrani', setSubTotal);
            }
        }

        function setSubTotal(values) {
            var aratop = parseFloat(txtAraToplam.GetText());
            var kdvtop = parseFloat(txtKdv.GetText());
            var yekun = parseFloat(txtYekun.GetText());

            aratop = aratop + (values[0]);
            txtAraToplam.SetText(aratop.toFixed(2));
            var kdvtop = aratop / 100 * values[1];
            txtKdv.SetText(kdvtop.toFixed(2))
            txtYekun.SetText((aratop + kdvtop).toFixed(2));
        }

        function ShowPopup(stokkodu, elementID) {
            var imageUrl = "images/B" + stokkodu + ".jpg";
            clientImage.SetImageUrl(imageUrl);
            setTimeout(function () {
                pcLogin.Show();
            },
                10);
        }
    </script>
</head>
<body>
    <div id="fatura" class="animate form">
        <form id="form1" runat="server">
            <dx:ASPxPopupControl ID="pcLogin" runat="server" CloseAction="CloseButton" Modal="false"
                PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter" ClientInstanceName="pcLogin"
                HeaderText="Ürün Resmi" AllowDragging="true" EnableViewState="False">
                <HeaderTemplate>
                    <div style="float: right">
                        <dx:ASPxImage ID="img" runat="server" ImageUrl="~/images/close.png" Cursor="pointer">
                            <ClientSideEvents Click="function(s, e){  pcLogin.Hide();}" />
                        </dx:ASPxImage>
                    </div>
                </HeaderTemplate>
                <ContentCollection>
                    <dx:PopupControlContentControl ID="PopupControlContentControl1" runat="server">
                        <dx:ASPxImage ID="ASPxImage1" ClientInstanceName="clientImage" runat="server">
                            <ClientSideEvents Click="function(s, e){ pcLogin.Hide(); }" />
                        </dx:ASPxImage>
                    </dx:PopupControlContentControl>
                </ContentCollection>
            </dx:ASPxPopupControl>
            <table>
                <tr>
                    <td>
                        <table class="auto-style1">
                            <tr>
                                <td class="auto-style18" style="text-align: justify;">C.Hesap İsmi</td>
                                <td class="auto-style10">
                                    <dx:ASPxTextBox ID="txtCariAdi" Width="400" runat="server" Theme="Youthful">
                                    </dx:ASPxTextBox>
                                </td>
                                <td class="auto-style14">
                                    <dx:ASPxButton ID="ASPxButton2" HorizontalAlign="Center" VerticalAlign="Middle" AutoPostBack="true" runat="server" Text="Cari Liste" Width="100px" Theme="Youthful" ClientInstanceName="btnAnaMenu" OnClick="ASPxButton2_Click">
                                    </dx:ASPxButton>
                                </td>
                                <td class="auto-style12">Evrak No</td>
                                <td class="auto-style16">
                                    <dx:ASPxTextBox ID="txtSeri" runat="server" Width="48" Theme="Youthful" ReadOnly="True">
                                    </dx:ASPxTextBox>
                                </td>
                                <td class="auto-style11">
                                    <dx:ASPxButtonEdit ID="txtSira" runat="server" Theme="Youthful" OnButtonClick="txtSira_ButtonClick" ReadOnly="True">
                                        <Buttons>
                                            <dx:EditButton>
                                            </dx:EditButton>
                                        </Buttons>
                                    </dx:ASPxButtonEdit>
                                </td>
                            </tr>
                            <tr>
                                <td class="auto-style19" style="text-align: justify; vertical-align: top;">Açıklama</td>
                                <td class="auto-style8">
                                    <dx:ASPxMemo ID="txtAciklama" runat="server" Height="71px" Width="265px">
                                    </dx:ASPxMemo>
                                </td>
                                <td class="auto-style15"></td>
                                <td class="auto-style13" style="text-align: justify; vertical-align: top">Tarih</td>
                                <td class="auto-style17" colspan="2" style="text-align: right; vertical-align: top">
                                    <dx:ASPxDateEdit ID="dteTarih" runat="server" Theme="Youthful">
                                    </dx:ASPxDateEdit>
                                </td>
                            </tr>
                            <tr>
                                <td>&nbsp;</td>
                                <td>
                                    <div style="float: left; clear: left; height: 30px; width: 110px;">
                                    </div>
                                    <div style="float: right; clear: right; width: 110px;">
                                        <dx:ASPxButton ID="ASPxButton1" AutoPostBack="false" runat="server" Text="Satır Sil" Width="100px" Theme="Youthful" ClientInstanceName="btnSatirSil">
                                            <ClientSideEvents Click="function(s, e) 
                                                    {  
                                                        GridLine.PerformCallback('satirsil;' + GridLine.GetFocusedRowIndex()); 
                                                        GridLine.Refresh();
                                                        CalcLines();
                                                    }" />
                                        </dx:ASPxButton>
                                    </div>
                                </td>
                                <td>
                                    <div style="float: right; clear: left; width: 50px;">Miktar</div>
                                </td>
                                <td class="auto-style13">
                                    <dx:ASPxTextBox ID="txtMiktar" runat="server" Theme="Youthful" Width="48px" ClientInstanceName="txtMiktar">
                                    </dx:ASPxTextBox>
                                </td>
                                <td>
                                    <div style="float: right; clear: left; width: 100%;">
                                        <dx:ASPxButton ID="btnGuncelle" AutoPostBack="false" runat="server" Text="Ekle" Width="100%" Theme="Youthful" ClientInstanceName="btnMiktar">
                                            <ClientSideEvents Click="function(s, e) 
                                                    {  
                                                        if(tabPage.GetActiveTab().index==1)
                                                        {
                                                            Guncelle(); 
                                                            GridLine.Refresh();
                                                            txtMiktar.SetText('');
                                                            CalcLines();
                                                        }
                                                        else
                                                        {
                                                            ProcessClick();
                                                            txtMiktar.SetText('');
                                                            //GridCallasp.ClearFilter();
                                                        }
                                                    }" />
                                        </dx:ASPxButton>
                                    </div>
                                </td>
                            </tr>

                        </table>
                    </td>
                </tr>
                <tr>
                    <td class="auto-style46">
                        <dxd:ASPxPageControl RenderMode="Lightweight" ID="tapPage1" ClientInstanceName="tabPage" runat="server" ActiveTabIndex="1" EnableHierarchyRecreation="True"
                            Height="380px" Width="100%">
                            <ClientSideEvents ActiveTabChanged="function(s, e) 
                                { 
                                    if(tabPage.GetActiveTab().index==1)
                                    {
                                        btnMiktar.SetText('Güncelle');
                                    }
                                    else
                                    {
                                        btnMiktar.SetText('Ekle');
                                    }
                                }" />
                            <TabPages>
                                <dxd:TabPage Text="Ürün Listesi">
                                    <ContentCollection>
                                        <dx:ContentControl runat="server" SupportsDisabledAttribute="True">
                                            <dx:ASPxGridView ID="ASPxGridView2" EnableCallBacks="true" ClientInstanceName="GridCallasp" SettingsBehavior-AllowSelectByRowClick="true" runat="server" EnableTheming="True" Theme="Youthful" Width="100%" AutoGenerateColumns="False" OnCustomCallback="ASPxGridView2_CustomCallback" OnHtmlDataCellPrepared="ASPxGridView2_HtmlDataCellPrepared">
                                                <ClientSideEvents EndCallback="function(s, e) { GridLine.Refresh(); }" />
                                                <Columns>
                                                    <dx:GridViewDataImageColumn FieldName="Kodu" VisibleIndex="0" Width="48" Caption="Resim">
                                                        <PropertiesImage ImageUrlFormatString="Images/K{0}.jpg">
                                                        </PropertiesImage>
                                                    </dx:GridViewDataImageColumn>
                                                    <dx:GridViewDataTextColumn FieldName="barkod" Caption="Barkodu" Width="80" VisibleIndex="1">
                                                    </dx:GridViewDataTextColumn>
                                                    <dx:GridViewDataTextColumn FieldName="Kodu" Caption="Stok Kodu" Width="100" VisibleIndex="2">
                                                    </dx:GridViewDataTextColumn>
                                                    <dx:GridViewDataTextColumn FieldName="Adi" Caption="Stok Adı" Width="300" VisibleIndex="3">
                                                    </dx:GridViewDataTextColumn>
                                                    <dx:GridViewDataTextColumn FieldName="Fiyat" Caption="Fiyat" Width="50" VisibleIndex="4">
                                                    </dx:GridViewDataTextColumn>
                                                    <dx:GridViewDataTextColumn FieldName="AnaGrupKodu" Caption="Ana Grp.Kodu" Width="75" VisibleIndex="5">
                                                    </dx:GridViewDataTextColumn>
                                                    <dx:GridViewDataTextColumn FieldName="AnaGrupAdi" Caption="Ana Grp.Adı" Width="100" VisibleIndex="6">
                                                    </dx:GridViewDataTextColumn>
                                                    <dx:GridViewDataTextColumn FieldName="MarkaKodu" Caption="Marka Kodu" Width="75" VisibleIndex="7">
                                                    </dx:GridViewDataTextColumn>
                                                    <dx:GridViewDataTextColumn FieldName="MarkaAdi" Caption="Marka Adı" Width="100" VisibleIndex="8">
                                                    </dx:GridViewDataTextColumn>
                                                </Columns>
                                                <SettingsBehavior AllowFocusedRow="True" />
                                                <SettingsBehavior AllowSelectByRowClick="True"></SettingsBehavior>
                                                <SettingsPager PageSizeItemSettings-ShowAllItem="true" Mode="ShowAllRecords" PageSize="99999999" Visible="False">
                                                    <PageSizeItemSettings ShowAllItem="True"></PageSizeItemSettings>
                                                </SettingsPager>
                                                <Settings ShowFilterRow="True" ShowHorizontalScrollBar="True" ShowVerticalScrollBar="True" />
                                            </dx:ASPxGridView>
                                        </dx:ContentControl>
                                    </ContentCollection>
                                </dxd:TabPage>
                                <dxd:TabPage Text="Satış">
                                    <ContentCollection>
                                        <dx:ContentControl ID="ContentControl1" runat="server" SupportsDisabledAttribute="True">
                                            <dx:ASPxGridView ID="ASPxGridView1" KeyFieldName="ID" EnableCallBacks="true" SettingsBehavior-AllowSelectByRowClick="true" runat="server" ClientInstanceName="GridLine" EnableTheming="True" Theme="Youthful" Width="100%" OnCustomCallback="ASPxGridView1_CustomCallback">
                                                <ClientSideEvents EndCallback="function(s, e) { if(teksefer) { CalcLines(); teksefer=false;  }  }" />
                                                <SettingsBehavior AllowFocusedRow="True" />
                                                <ClientSideEvents Init="function(s, e) { CalcLines(); }" />
                                                <Columns>
                                                    <dx:GridViewDataTextColumn FieldName="Kodu" Caption="Stok Kodu" Width="100" VisibleIndex="1">
                                                    </dx:GridViewDataTextColumn>
                                                    <dx:GridViewDataTextColumn FieldName="Adi" Caption="Stok Adı" Width="200" VisibleIndex="2">
                                                    </dx:GridViewDataTextColumn>
                                                    <dx:GridViewDataTextColumn FieldName="Fiyat" Caption="Fiyat" Width="50" VisibleIndex="3">
                                                    </dx:GridViewDataTextColumn>
                                                    <dx:GridViewDataTextColumn FieldName="Miktar" Caption="Miktar" Width="50" VisibleIndex="4">
                                                    </dx:GridViewDataTextColumn>
                                                    <dx:GridViewDataTextColumn FieldName="Tutar" Caption="Tutar" Width="50" VisibleIndex="5">
                                                    </dx:GridViewDataTextColumn>
                                                </Columns>
                                                <SettingsBehavior AllowSelectByRowClick="True"></SettingsBehavior>
                                                <SettingsPager PageSizeItemSettings-ShowAllItem="true" Mode="ShowAllRecords" PageSize="99999999" Visible="False">
                                                    <PageSizeItemSettings ShowAllItem="True"></PageSizeItemSettings>
                                                </SettingsPager>
                                                <Settings ShowHorizontalScrollBar="True" ShowVerticalScrollBar="True" />
                                            </dx:ASPxGridView>
                                        </dx:ContentControl>
                                    </ContentCollection>
                                </dxd:TabPage>
                            </TabPages>
                        </dxd:ASPxPageControl>
                    </td>
                </tr>
                <tr>
                    <td>
                        <table class="auto-style30">
                            <tr>
                                <td class="auto-style32">
                                    <table class="auto-style44" style="float: right; vertical-align: top; height: 128px;">
                                        <tr>
                                            <td>
                                                <dx:ASPxTextBox ID="txtAciklama1" runat="server" Theme="Youthful" Width="100%">
                                                </dx:ASPxTextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="1">
                                                <dx:ASPxTextBox ID="txtAciklama2" runat="server" Theme="Youthful" Width="100%">
                                                </dx:ASPxTextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <dx:ASPxTextBox ID="txtAciklama3" runat="server" Theme="Youthful" Width="100%">
                                                </dx:ASPxTextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <dx:ASPxTextBox ID="txtAciklama4" runat="server" Theme="Youthful" Width="100%">
                                                </dx:ASPxTextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <dx:ASPxTextBox ID="txtAciklama5" runat="server" Theme="Youthful" Width="100%">
                                                </dx:ASPxTextBox>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                                <td class="auto-style33">
                                    <table class="auto-style30">
                                        <tr>
                                            <td class="auto-style40"></td>
                                            <td class="auto-style41"></td>
                                            <td class="auto-style41"></td>
                                            <td class="auto-style42"></td>
                                            <td class="auto-style43"></td>
                                        </tr>
                                        <tr>
                                            <td class="auto-style39">&nbsp;</td>
                                            <td class="auto-style38">
                                                <dx:ASPxButton ID="btnKaydet" runat="server" ImagePosition="Top" Text="Sakla" Theme="Youthful" Width="85px" OnClick="btnKaydet_Click" AutoPostBack="False">
                                                    <ClientSideEvents Click="function(s, e) {  e.processOnServer = confirm('Kaydetmek istediğinize eminmisiniz ?');}" />
                                                    <Image Url="~/images/save.png">
                                                    </Image>
                                                </dx:ASPxButton>
                                            </td>
                                            <td class="auto-style38">
                                                <dx:ASPxButton ID="btnYeni" runat="server" ImagePosition="Top" Text="Yeni" Theme="Youthful" Width="85px" OnClick="btnYeni_Click">
                                                    <Image Url="~/images/add.png">
                                                    </Image>
                                                </dx:ASPxButton>
                                            </td>
                                            <td class="auto-style37">
                                                <dx:ASPxButton ID="btnSil" runat="server" ImagePosition="Top" Text="Sil" Theme="Youthful" Width="85px" AutoPostBack="False" OnClick="btnSil_Click">
                                                    <ClientSideEvents Click="function(s, e) {  e.processOnServer = confirm('Evrağı tamamen silmek istediğinize eminmisiniz ?');}" />
                                                    <Image Url="~/images/Delete.png">
                                                    </Image>
                                                </dx:ASPxButton>
                                            </td>
                                            <td>&nbsp;</td>
                                        </tr>
                                    </table>
                                </td>
                                <td>
                                    <table class="auto-style30">
                                        <tr class="auto-style31">
                                            <td class="auto-style24" style="font-weight: bold">Ara Toplam</td>
                                            <td class="auto-style24" style="float: right;">
                                                <dx:ASPxTextBox ID="txtAraToplam" ClientInstanceName="txtAraToplam" runat="server" Theme="Youthful" Width="170px" HorizontalAlign="Right" ReadOnly="True" Text="0">
                                                </dx:ASPxTextBox>
                                            </td>
                                        </tr>

                                        <tr>
                                            <td class="auto-style34" style="font-weight: bold">Kdv</td>
                                            <td class="auto-style34" style="float: right">
                                                <dx:ASPxTextBox ID="txtKdv" ClientInstanceName="txtKdv" runat="server" Theme="Youthful" Width="170px" HorizontalAlign="Right" ReadOnly="True" Text="0">
                                                </dx:ASPxTextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="font-weight: bold">Yekün</td>
                                            <td style="float: right">
                                                <dx:ASPxTextBox ID="txtYekun" ClientInstanceName="txtYekun" runat="server" Theme="Youthful" Width="170px" HorizontalAlign="Right" ReadOnly="True" Text="0">
                                                </dx:ASPxTextBox>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </form>
    </div>
</body>
</html>
